/**
 * Contains general utilities that can be used between the <em>Mastermind</em> client and server.
 */
package com.mastermind.util;

import java.util.Calendar;

/**
 * Contains some basic utilities methods used for console output .
 * 
 * @author Pedram Balalzadeh, Phillipe Thibault, Alan Ly
 * @version 1.2
 */
public class ConsoleUtilities {
    
    /**
     * Generates an appropriate time stamp for insertion into status messages. This method returns the current date and time in a string.
     * 
     * An example of the timestamp generated by this code is,
     * <blockquote>
     * 29/05/2010 22:07:34
     * </blockquote>
     * 
     * @return the current date and time in a string
     */
    public static String generateTimeStamp() {
		Calendar calendar = Calendar.getInstance();
		
		return calendar.get(Calendar.DAY_OF_MONTH) + "/" + (calendar.get(Calendar.MONTH) + 1) 
		+ "/" + calendar.get(Calendar.YEAR) + " " + calendar.get(Calendar.HOUR_OF_DAY) + ":" 
		+ calendar.get(Calendar.MINUTE) + ":" + calendar.get(Calendar.SECOND);
    }
    
    /**
     * Makes use of the <em>generateTimeStamp()</em> method to create a user-friendly console log header to identify Mastermind Server messages.
     * 
     * An example of the header generated by ths code is,
     * <blockquote>
     * [29/05/2010 22:07:34] mastermind-server: 
     * </blockquote>
     * 
     * @return a log header with the current timestamp
     */
    public static String generateLogHeader() {
    	return "[" + generateTimeStamp() + "] mastermind-server: ";
    }
    
}
